Execute Stored Procedure
AutomatR.MySQLDataBase.Database.ExecuteStoredProcedure
The "Execute Stored Procedure" activity in AutomatR is designed to execute a stored procedure on a MySQL database. This activity facilitates the execution of complex database operations and provides flexibility in handling input parameters, output parameters, and result sets.
Properties
Name | Description |
---|---|
Input | |
Connection | Provide a MySqlConnection variable used to establish a connection to the MySQL database. Variables of type MySqlConnection. |
Procedure Name | Provide the name of the stored procedure specified in the SQL parameter. String variables containing the stored procedure name. |
Misc | |
Display Name | Provides a customizable name for the activity displayed in the workflow. The display name enhances clarity and organization within the automation project. String variables containing the desired display name. |
Optional | |
Command Timeout | Provide the amount of time (in milliseconds) to wait for the SQL command to run before throwing an error. Integer variables containing the timeout duration. If not specified, a default timeout of 60 seconds is applied. |
Delay | Specifies the amount of time (in seconds) to wait before executing the "Execute Stored Procedure" activity. This can be useful for handling synchronization issues. Integer variables containing the delay duration. Ex.: If the amount of time is 1000 milliseconds or 1 sec, i.e., 1. |
Output | |
Result | The result of the SQL command will be stored in a DataSet variable, allowing you to utilize it in subsequent activities or operations. Variables of type DataSet to store the query result. |
Out Variables | Provides a Dictionary containing out-direction parameters and their values after executing the stored procedure. Variables of type Dictionary<string, object> to store the output parameters. |
Parameters: The "Execute Stored Procedure" activity supports both input and output parameters. Parameters are configured using the "Parameters" property, which is a dictionary containing parameter names and associated properties.
Input Parameters (Direction: In): Specify input parameters by adding key-value pairs to the "Parameters" dictionary, where the key is the parameter name, and the value is the argument representing the parameter's value.
Output Parameters (Direction: Out): Specify output parameters by adding key-value pairs to the "Parameters" dictionary, where the key is the parameter name, and the value is the argument representing the parameter's value. The direction is set to "Out" for output parameters.
How to use:
- Drag and drop the "Execute Stored Procedure" activity onto the workflow.
- Configure the properties by specifying the MySqlConnection variable, stored procedure name, and other optional settings.
- Define input parameters using the "Parameters" property. Add key-value pairs for each input parameter, where the key is the parameter name, and the value is the argument representing the parameter's value.
- Define output parameters using the "Parameters" property. Add key-value pairs for each output parameter, where the key is the parameter name, and the value is the argument representing the parameter's value. Set the direction to "Out" for output parameters.
- Optionally, configure the command timeout and delay for synchronization purposes.
- Execute the workflow to run the specified stored procedure on the MySQL database, retrieve the result as a DataSet, and store output parameters for further use.
Example: Consider an example where the "Execute Stored Procedure" activity is used to execute a stored procedure named "GetEmployeeDetails" with input parameters "EmpID" and "Department" and output parameter "EmployeeCount."
Execute Stored Procedure:
Connection: MySqlConnectionVariable
Procedure Name: "GetEmployeeDetails"
Parameters:
EmpID: EmpIDVariable (Direction: In)
Department: "HR" (Direction: In)
EmployeeCount: EmployeeCountVariable (Direction: Out)
Command Timeout: 5000
Result: EmployeeDetailsDataSet
Out Variables: OutputParametersDictionary
In this example, the activity executes the "GetEmployeeDetails" stored procedure with input parameters "EmpID" and "Department." The result is stored in the DataSet variable "EmployeeDetailsDataSet," and output parameters are stored in the Dictionary variable "OutputParametersDictionary" for further handling in the workflow.